$def with(book, size="S", cover_url=False)

$ title = book.title
$ author_names = ", ".join(a.get("name", "Name missing") for a in book.get_authors()) or book.get('by_statement','')

$# Use cover URL if provided by the caller.
$# This is used to avoid a solr query for editions with work.edition_count == 1
$if cover_url is False:
    $ cover_url = book.get_cover_url(size)

$if size == "S":
    <div class="coverMagic">
            <div class="SRPCover bookCover" style="display: $cond(cover_url, 'block', 'none');">
                <a href="$book.key" title="$_('Go to the main page for %(title)s', title=title)"><img src="$cover_url" class="cover" alt="$_('Cover of: %(title)s by %(authors)s', title=title, authors=author_names)"/></a>
            </div>
            <div class="SRPCoverBlank" style="display: $cond(not cover_url, 'block', 'none');clear:left;">
                <a href="$book.key" title="$_('Go to the main page for %(title)s', title=title)"><img src="/images/icons/avatar_book-sm.png" height="58" alt="$_('We need a book cover for: %(title)s', title=title)"/></a>
            </div>
    </div>
$else:
    <img src="$(cover_url or '/images/icons/avatar_book-sm.png')" height="58" title="$_('Go to the main page for %(title)s', title=title)" alt="$title"/>
